// 导入vuex配置项
import Vue from 'vue'
import Vuex from 'vuex'
// 挂载vuex
Vue.use(Vuex)

// 暴露全局状态--App.vue导入一次即可
export default new Vuex.Store({
    state: {
        // 全局状态
        adminname: localStorage.getItem('adminname'),
        loginState: localStorage.getItem('loginState') == 'true',
        token: localStorage.getItem('token'),
        role: localStorage.getItem('role'),
        checkedkeys: JSON.parse(localStorage.getItem('checkedkeys'))
    },
    getters: {
        // 
    },
    mutations: {
        // 唯一修改状态的方法
        changeAdminname(state, value) {
            state.adminname = value
        },
        changeLoginState(state, value) {
            state.loginState = value
        },
        changeToken(state, value) {
            state.token = value
        },
        changeRole(state, value) {
            state.role = value
        },
        changeCheckedkeys(state, value) {
            state.checkedkeys = value
        }
    },
    actions: {
        // 异步修改状态--需调用mutations的方法
    },
    modules: {
        // 模块化--状态分片

    }
})